using MediatR;
using Microsoft.AspNetCore.Mvc;
using RBAC.ErrorCode;
using SmartHealthcare.Write.Api.Application.Command.Pharmacy;
using SmartHealthcare.Write.Api.DTo;

namespace SmartHealthcare.Write.Api.Controllers
{
    /// <summary>
    /// 药房管理控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PharmacyController : ControllerBase
    {
        private readonly IMediator _mediator;

        public PharmacyController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 打单操作
        /// </summary>
        /// <param name="request">打单请求</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>操作结果</returns>
        [HttpPost]
        public Task<APIResult<PharmacyOperationDto>> PrintPrescription([FromBody] PrintPrescriptionCommand request, CancellationToken cancellationToken)
        {
            return _mediator.Send(request, cancellationToken);
        }

        /// <summary>
        /// 发药操作
        /// </summary>
        /// <param name="request">发药请求</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>操作结果</returns>
        [HttpPost]
        public Task<APIResult<PharmacyOperationDto>> DispenseMedicine([FromBody] DispenseMedicineCommand request, CancellationToken cancellationToken)
        {
            return _mediator.Send(request, cancellationToken);
        }
    }
} 